import obServer from './obServer/index.js';
import Ast from './ast/index.js';
import {lifecycleMixin , mountComponent} from './lifecycle/lifecycle';
import {renderMixin} from './vdom';
import {compilerToRenderFuntion} from './compiler';
import test from '../dist/test.vue'
function Water(options) {
    this.$options = options;
    this.$el = options.el.nodeType === 1 ? options.el : document.querySelector(options.el);
    this.str = options.str;
    this.data = options.data;
    this.$data = options.data;
    this.$children = [];
    //console.log(test)
    // if(options.components && Object.keys(options.components).length>0){
    //   // this.$children.push(new Water)
    //   for (let key in options.components) {
    //     console.log(options.components[key])
        
    //   }
    // }
    //修改data为响应式
    new obServer(this.data,this);
    //template转换语法树
    const ast = new Ast(this.$el,this.data,this);
    // console.log(ast)
    //生成render并挂载函数
    this.$options.render = compilerToRenderFuntion(ast,this)
    console.log(this.$options.render)
    // initMixin();
    
    
    //初始化渲染函数的方法_c
    renderMixin(this);
    //添加update方法
  lifecycleMixin(this);
  //执行update方法
  mountComponent(this);
}

window.Water = Water
